from dataclasses import dataclass

from src.application.user import dto
from src.application.user.converters import convert_active_user_entity_to_dto
from src.application.user.uow import UserUoW
from src.domain.user.value_objects import TelegramUserId


@dataclass(frozen=True)
class GetUserByTgId:
    user_tg_id: int


class GetUserByTgIdHandler:
    """
    Получение пользователя по telegram id
    """

    def __init__(self, *, uow: UserUoW) -> None:
        self._uow = uow

    async def __call__(self, command: GetUserByTgId) -> dto.UserDTO:
        user = await self._uow.user_reader.get_user_by_tg_id(user_tg_id=command.user_tg_id)

        return user
